 #include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<list>
#include<cstdlib>
#include<cmath>
#include<sstream>
#include<numeric>
#include<cstdio>
#include<cstring>
#include<stack>
using namespace std;
typedef long long LL;
LL b[100];
int getu(int x){
	int c=0;
	for(int i=2;i<=x;i++)if(x%i==0){
		x/=i;c++;
		if(x%i==0)return 0;
		}
	return c%2==1?1:-1;
	}
LL cal(LL x){
	if(!x)return 0;
	LL ans=0;
	for(int i=2;i<64;i++){//block num
		LL u=getu(i);
		for(int j=1;j<64;j++){//size
			LL res1=1LL<<(j-1),t=1;
			for(int k=1;k<i;k++)t=(t<<j)+1;
			LL res2=min(x/t,b[j]-1);
			ans+=max(0LL,res2-res1+1)*u;
			}
		}
	return ans;
	}
int main(){
	b[0]=1;for(int i=1;i<63;i++)b[i]=b[i-1]*2;
	LL l,r;
	while(cin>>l>>r){
		cout<<cal(r)-cal(l-1)<<endl; 
		} 
    return 0;
    }
